// pages/personal_center/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    host:'',
    operate_list:[
      {
        title:'地址管理',
        img:'http://n.tuku321.com/static/mobile/image/icon_address.png'
      },
      {
        title:'退回国内',
        img:'http://n.tuku321.com/static/mobile/image/icon_tuihui.png'
      },
      {
        title:'消息通知',
        img:'http://n.tuku321.com/static/mobile/image/icon_xiaoxi.png'
      },
      {
        title:'建议我们',
        img:'http://n.tuku321.com/static/mobile/image/icon_jianyi.png'
      },
      {
        title:'清除缓存',
        img:'http://n.tuku321.com/static/mobile/image/icon_qingchu.png'
      },
      {
        title:'系统设置',
        img:'http://n.tuku321.com/static/mobile/image/icon_shezhi .png'
      },
    ],
    avatar:'',
    mobile:'',
    nickname:'',
    user_money:'0.00',
    id:'',
    theme_color:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      host:app.dlc.host
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.get_userInfo()
    this.getTabBar().init()
    this.setData({
      theme_color:app.dlc.gain('theme_color')
    })
  },
  officialAccount(){
    wx.navigateTo({
      url: '/personal_center/pages/userAgreement/index',
    })
  },
  editor_personal(){
    wx.navigateTo({
      url: '/personal_center/pages/editor_personal/index',
    })
  },
  openMembership(){
    wx.navigateTo({
      url: '/personal_center/pages/openMembership/index',
    })
  },
  accountBalance(){
    wx.navigateTo({
      url: '/personal_center/pages/accountBalance/index',
    })
  },
  insuredPrice(){
    wx.navigateTo({
      url: '/personal_center/pages/insuredPrice/index',
    })
  },
  coupon(){
    wx.navigateTo({
      url: '/personal_center/pages/coupon/index',
    })
  },
  get_index(e){
    console.log(e)
    let index=e.currentTarget.dataset.index;
    if(index==0){
      wx.navigateTo({
        url: '/personal_center/pages/addressManagement/index',
      })
    }else if(index==1){
      wx.navigateTo({
        url: '/personal_center/pages/returnToCountry/index',
      })
    }else if(index==2){
      wx.navigateTo({
        url: '/personal_center/pages/Notification/index',
      })
    }else if(index==3){
      wx.navigateTo({
        url: '/personal_center/pages/suggest/index',
      })
    }else if(index==4){
      
    }else if(index==5){
      wx.navigateTo({
        url: '/personal_center/pages/setUp/index',
      })
    }
  },
  get_userInfo(){
    const that=this;
    app.wxRequest('/api/Users/info',{},function(res){
      if(res.code==200){
          that.setData({
            avatar:res.data.avatar,
            mobile:res.data.mobile,
            nickname:res.data.nickname,
            user_money:res.data.user_money
          })
      }else{
        app.toast(res.message)
      }
    },'get')
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})